package framework.system.service;

import java.util.List;
import java.util.Set;

import org.hibernate.criterion.DetachedCriteria;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import framework.core.util.ListRange;
import framework.system.entity.SysResource;
import framework.system.entity.front.TreeNode;

/** 
 * @ClassName: IMenuService 
 * @Description: 资源Servie接口
 * @author: Ching Wang
 * @date 2013-5-18 下午2:22:57 
 *
 */
@Service("menuService")
@Transactional(readOnly = false, propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
public interface IMenuService{
	
	/**
	 * @Title: loadTree 
	 * @Description: 查询资源树
	 * @param userId 用户ID
	 * @param type 查询资源树节点类型（menu,all）
	 * @return List<TreeNode>
	 * @throws Exception
	 */
	@Transactional(readOnly = true)
	public abstract List<TreeNode> loadTree(String userId, String type) throws Exception;

	/**
	 * @Title: loadAut 
	 * @Description: 查询权限
	 * @param userId 用户ID
	 * @param type 查询资源树节点类型（menu,all）
	 * @return Set<String>
	 * @throws Exception
	 * @throws
	 */
	@Transactional(readOnly = true)
	public abstract Set<String> loadAut(String userId) throws Exception;
	
	/**
	 * @Title: getResource 
	 * @Description: 通过资源ID获取资源信息 
	 * @param resouceId 资源ID
	 * @return SysResource
	 * @throws Exception
	 */
	@Transactional(readOnly = true)
	public abstract SysResource getResource(String resouceId) throws Exception;

	/** 
	 * @Title: getCount 
	 * @Description: 获取符合条件的资源总数
	 * @param criteria 查询条件集合
	 * @return long
	 * @throws Exception
	 */
	public abstract long getCount(DetachedCriteria criteria) throws Exception;

	/**
	 * @Title: saveOrUpdate 
	 * @Description: 保存或更新资源
	 * @param resource 资源实体对象
	 * @param opres 资源实体对象的上级节点
	 * @throws Exception
	 */
	public abstract void saveOrUpdate(SysResource resource, SysResource opres) throws Exception;

	/** 
	 * @Title: delRes 
	 * @Description: 删除资源节点信息 
	 * @param resIds 资源节点集合
	 * @return ListRange<TreeNode>
	 * @throws Exception
	 */
	public abstract ListRange<TreeNode> delRes(String[] resIds) throws Exception;

	/** 
	 * @Title: loadOper 
	 * @Description: 加载属性为button资源
	 * @param uid 用户编号
	 * @param resId 上级资源ID
	 * @return List<SysResource>
	 * @throws Exception
	 */
	@Transactional(readOnly = true)
	public abstract List<SysResource> loadOper(String uid, String resId) throws Exception;

	/**
	 * @Title: seqRes 
	 * @Description: 调整资源树节点顺序
	 * @param resId 资源ID
	 * @param type 调整类型
	 * @return ListRange<SysResource> 
	 * @throws Exception
	 */
	public abstract ListRange<SysResource> seqRes(String resId, String type) throws Exception;

}
